package IC.Types;

public class PrimitiveType extends Type {

    private PrimitiveTypeKind primitiveTypeKind; 

    public PrimitiveType(PrimitiveTypeKind primitiveTypeKind) {
        super(primitiveTypeKind.getName());
        this.primitiveTypeKind = primitiveTypeKind;
    }
    
    public String toString() {
        return String.format("%d: Primitive type: %s", getTypeId(),getTypeName());
    }

    public boolean isRef() {
        return (primitiveTypeKind == PrimitiveTypeKind.NULL || primitiveTypeKind == PrimitiveTypeKind.STRING);
    }

    public boolean isSub(Type ty) {
        if (primitiveTypeKind == PrimitiveTypeKind.NULL)
            return ty.isRef();
        return (ty==this);
    }

}